package com.oocl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.pojo.Customer;
import com.oocl.service.CustomerManager;
import com.oocl.service.impl.CustomerManagerFactory;

public class AllCustomerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CustomerManager manager;
       
    public AllCustomerServlet() {
        super();
        manager = CustomerManagerFactory.getInstance();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Customer> customers = manager.findAllCustomers();
		request.setAttribute("customers", customers);
		System.out.println(customers.size());
		for (Customer customer : customers) {
			System.out.println(customer);
		}
		request.getRequestDispatcher("list.jsp").forward(request, response);
	}

}
